import {Component, OnInit, Input,} from '@angular/core';
import {TagData} from '../../../../entity/tag-data.model';

@Component({
  selector: 'app-inverter-detail-system',
  templateUrl: './inverter-detail-system.component.html',
  styleUrls: ['./inverter-detail-system.component.css']
})
export class InverterDetailSystemComponent implements OnInit {

  @Input() title: string;
  @Input() image: Images;
  @Input() data: TagData[];

  private curWwwPath: string;
  private pathName: string;
  private pos: number;
  private localhostPath: string;
  /**
   * 开关量为1时颜色
   *
   * @type {string}
   * @memberof InverterDetailSystemComponent
   */
  @Input() switchingValue1: string;
  /**
   * 开关量为0时颜色
   *
   * @type {string}
   * @memberof InverterDetailSystemComponent
   */
  @Input() switchingValue2: string;

  constructor() {
  }

  ngOnInit() {
    this.curWwwPath = window.location.href;
    this.pathName = window.location.pathname;
    this.pos = this.curWwwPath.indexOf(this.pathName);
    this.localhostPath = this.curWwwPath.substring(0, this.pos);
    if (this.localhostPath.indexOf('localhost') == -1) {
      this.localhostPath = this.localhostPath + '/dist';
    }
  }
}

interface Images {
  icon?: string;
  iconHover?: string;
  titleImage?: string;
  bgImage?: string;
}
